<?php
/**
 *  This class inhabits the functionality to assemble the 
 *  mail body
 * 
 *  @author mario
 *  @package Mailgun
 *  @license http://www.gnu.org/licenses/lgpl.html LGPL
 */
class Mailgun_Body {

    /**
     *  the feed url
     * 
     *  @access private
     */
    private $feedUrl = '';

    /**
     *  constructor
     */
    public function __construct(){
     
    }

    /**
     *  fetches the feed data and concatenates the items to one 
     *  string
     */
    public function getVectorsFromRSS() {
       
        $body = '';
        $source = file_get_contents($this->feedUrl);
       
        try {
            $feed = new XML_Feed_Parser($source);
            
            foreach ($feed as $entry) {
                $body .= $entry->description;
            }
            
        } catch (XML_Feed_Parser_Exception $e) {
            die('Feed invalid: ' . $e->getMessage());
        }
    
        return $body;
    }

    /**
     *  
     */
    public function setFeedUrl($feedUrl = null) {
        if(!empty($feedUrl)){
            $this->feedUrl = $feedUrl;
        } else {
            throw new InvalidArgumentException('Invalid feed url given');    
        }
    } 

}